module WhoCharted
  module ChartFeatures
    module Colors
      module ClassMethods
        def accepted_arguments
          super + [:colors]
        end

        def argument_dictionary
          super.merge(:colors => \
                      {:key => 'chco', :method => :gather_colors})
        end
      end

      def self.included base
        base.extend(ClassMethods)
      end

      def gather_colors
        if colors.class == Array
          colors[0].class == Array ? \
          colors.map {|c| c.join('|')}.join(',') : \
          colors.join(',')
        else
          colors
        end
      end

      attr_reader :colors

      private
      
      attr_writer :colors
    end
  end
end
